package com.suarte.core;

import com.suarte.utils.Persistent;
import org.appfuse.model.BaseObject;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * @date   Dec 29, 2010
 * @author Ggutierrez
 */
@Entity @Table(name = "sa_delivery_times")
public class DeliveryTime extends BaseObject implements Persistent {

    private Long id;
    private String description;
    private Integer days;
    private Long oldId;

    public DeliveryTime() {
    }

    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="DELIVERY_TIME_SEQ")
    @SequenceGenerator(name="DELIVERY_TIME_SEQ", sequenceName="DELIVERY_TIME_SEQ",allocationSize=1)
    public Long getId() {
        return id;
    }

    @Column(name = "description", length = 100)
    public String getDescription() {
        return description;
    }

    @Column(name = "days", length = 10)
    public Integer getDays() {
        return days;
    }

    @Column(name = "old_id")
    public Long getOldId() {
        return oldId;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setDays(Integer days) {
        this.days = days;
    }

    public void setOldId(Long oldId) {
        this.oldId = oldId;
    }

    @Override
    public String toString() {
        return description + " - " + days.toString() + " dias.";
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if (!(other instanceof DeliveryTime)) {
            return false;
        }
        DeliveryTime _i = (DeliveryTime) other;
        return id.equals(_i.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}
